﻿using Microsoft.AspNetCore.Mvc;
using Single.Core.Service;
using Single.Sys.Entity;
using Single.WebApp.Components;

namespace Single.WebApp.Areas.Sys.Controllers
{
    [Area("Sys")]
    public class FunctionController : WorkController
    {
        public IActionResult Index()
        {
            return View();
        }

        public string Get(long id)
        {
            var entity = ServiceSysProps.SysFunction.Get(id);

            return ServiceResult.SerializeData(entity);
        }

        public string GetData(int pageNum, int pageSize, string title, string remark)
        {
            var rows = ServiceSysProps.SysFunction.GetPageList(pageNum, pageSize, title, remark, out int total);

            return ServiceResult.SerializeData(new { rows, total });
        }

        public string Save(SysFunction entity)
        {
            return ServiceSysProps.SysFunction.InsertOrUpdate(entity).Serialize();
        }

        public string SortableDrag(long[] ids, int[] sequences)
        {
            return ServiceSysProps.SysFunction.SortableDrag(ids, sequences).Serialize();
        }

        public string Delete(long[] ids)
        {
            return ServiceSysProps.SysFunction.Delete(ids).Serialize();
        }
    }
}